<?php

use yii\grid\GridView;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $searchModel frontend\models\BranchSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Branches';
$this->params['breadcrumbs'][] = $this->title;
?>

<h1><?= $this->title ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>

<p>
    <button type="button" data-toggle="modal" data-target="#branchCreateModal" class="btn btn-success">Create From Modal</button>
</p>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'rowOptions' => function ($model) {
        if ($model->status == 'inactive') {
            return ['class' => 'danger'];
        }
        return ['class' => 'success'];
    },
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        //'id',
        'name',
        'address',
        'created_at',
        //'status',
        // 'company_id',
        ['attribute' => 'company_id', 'value' => 'company.name'],

        ['class' => 'yii\grid\ActionColumn'],
    ],
]); ?>

<div class="modal fade" id="branchCreateModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">Create Branch</h4></div>
            <div class="modal-body"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>